package org.itboys.ace.web.lasted;




import org.itboys.admin.service.lasted.SundayAreaService;

import org.itboys.commons.utils.ajax.AjaxUtils;

import org.itboys.framework.spring.controller.BaseController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 包名：com.hz.sunday.tianjie.entity.mysql.product
 * 作者 : 江雄
 * Email: empty90911@126.com
 * 时间：2016年3月10日 下午2:52:46
 * 描述: 圣代_省（直辖市）/市/区or县/街道or乡镇_controller。四级行政区划
 *
 */
@Controller
@RequestMapping("/sunday/web/area")
public class SundayAreaController extends BaseController {


	@Autowired
	private SundayAreaService areaService;

	/**
	 *
	 * @param request
	 * @param response
	 * @param isCludeTown//是否需要乡镇数据。如果是含有乡镇数据，不建议使用此方法
	 */
	@RequestMapping("/getAreaTree")
	public void getAreaTree(
			HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam(value="isCludeTown",required=true)boolean isCludeTown){

		AjaxUtils.renderJson(response, areaService.getAreaTree(isCludeTown));


	}

	/**
	 * 获取省
	 * @param request
	 * @param response
	 */

	@RequestMapping("/getProvince")
	public void getProvince(
			HttpServletRequest request,
			HttpServletResponse response){
		AjaxUtils.renderJson(response, areaService.getProvince());
	}

	/**
	 * 获取市
	 * @param request
	 * @param response
	 * @param provinceId
	 */
	@RequestMapping("/getCity")
	public void getCity(
			HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam(value="provinceId",required=true)Long provinceId){
		//List<Map<String,Object>> citys = areaService.getCity(provinceId);
		AjaxUtils.renderJson(response,areaService.getCity(provinceId));
	}
	/**
	 * 获取区县
	 * @param request
	 * @param response
	 * @param cityId
	 */
	@RequestMapping("/getDistrict")
	public void getDistrict(
			HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam(value="cityId",required=true)Long cityId){

		AjaxUtils.renderJson(response, areaService.getDistrict(cityId));
	}
	/**
	 * 获取乡镇街道
	 * @param request
	 * @param response
	 * @param districtId
	 */
	@RequestMapping("/getTown")
	public void getTown(
			HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam(value="districtId",required=true)Long districtId){

		AjaxUtils.renderJson(response, areaService.getTown(districtId));
	}

}
